package com.meichis.yndms.ui.activity;

import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;

import com.meichis.yndms.R;
import com.meichis.yndms.databinding.ActivityAccountBinding;
import com.meichis.yndms.ui.common.BaseActivity;
import com.meichis.yndms.vm.AccountVM;

public class AccountActivity extends BaseActivity {

    private ActivityAccountBinding binding;
    private AccountVM vm;


    @Override
    protected void setDataBindingContentView() {
        binding = DataBindingUtil.setContentView(this, R.layout.activity_account);
        vm = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(AccountVM.class);
        binding.setVm(vm);
        binding.setLifecycleOwner(this);
    }

    @Override
    protected void init() {
        binding.txtTitle.setText("往来账款");
        binding.navBack.setOnClickListener(v -> onBackPressed());
        addObserver();
        vm.GetCurrentAccount();
    }

    private void addObserver() {
        vm.getShowDialog().observe(this, aBoolean -> showLoading(aBoolean));
    }

}

